Skip to content

Conversation

@satyajanga
Copy link
Contributor

@satyajanga satyajanga commented Jul 23, 2025

Some gdb remote servers send target.xml that contains

<reg name='ft0' bitsize='32' type='ieee_single' dwarf_regnum='32'/>
  <reg name='ft1' bitsize='32' type='ieee_single' dwarf_regnum='33'/>
  <reg name='ft2' bitsize='32' type='ieee_single' dwarf_regnum='34'/>
  <reg name='ft3' bitsize='32' type='ieee_single' dwarf_regnum='35'/>
  <reg name='ft4' bitsize='32' type='ieee_single' dwarf_regnum='36'/>
  <reg name='ft5' bitsize='32' type='ieee_single' dwarf_regnum='37'/>
  <reg name='ft6' bitsize='32' type='ieee_single' dwarf_regnum='38'/>
  <reg name='ft7' bitsize='32' type='ieee_single' dwarf_regnum='39'/>

it seems like a valid and supported type in gdb.
from gdb16.3/gdb/target_descriptions.c (could not find a way to link it).

case TDESC_TYPE_IEEE_SINGLE:
	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_single",
				    floatformats_ieee_single);
	  return;

case TDESC_TYPE_IEEE_DOUBLE:
	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_double",
				    floatformats_ieee_double);
	  return;

Testplan

updated unittest to test this.

Reviewers: @clayborg , @jeffreytan81 , @Jlalond

@satyajanga satyajanga marked this pull request as ready for review July 27, 2025 21:29
@satyajanga satyajanga requested a review from JDevlieghere as a code owner July 27, 2025 21:29
@llvmbot llvmbot added the lldb label Jul 27, 2025
@llvmbot
Copy link
Member

llvmbot commented Jul 27, 2025

@llvm/pr-subscribers-lldb

Author: satyanarayana reddy janga (satyajanga)

Changes

Some gdb remote servers send target.xml that contains

&lt;reg name='ft0' bitsize='32' type='ieee_single' dwarf_regnum='32'/&gt;
  &lt;reg name='ft1' bitsize='32' type='ieee_single' dwarf_regnum='33'/&gt;
  &lt;reg name='ft2' bitsize='32' type='ieee_single' dwarf_regnum='34'/&gt;
  &lt;reg name='ft3' bitsize='32' type='ieee_single' dwarf_regnum='35'/&gt;
  &lt;reg name='ft4' bitsize='32' type='ieee_single' dwarf_regnum='36'/&gt;
  &lt;reg name='ft5' bitsize='32' type='ieee_single' dwarf_regnum='37'/&gt;
  &lt;reg name='ft6' bitsize='32' type='ieee_single' dwarf_regnum='38'/&gt;
  &lt;reg name='ft7' bitsize='32' type='ieee_single' dwarf_regnum='39'/&gt;

it seems like a valid and supported type in gdb.
from gdb16.3/gdb/target_descriptions.c (could not find a way to link it).

case TDESC_TYPE_IEEE_SINGLE:
	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_single",
				    floatformats_ieee_single);
	  return;

case TDESC_TYPE_IEEE_DOUBLE:
	  m_type = init_float_type (alloc, -1, "builtin_type_ieee_double",
				    floatformats_ieee_double);
	  return;

Testplan

updated unittest to test this.


Full diff: https://github.com/llvm/llvm-project/pull/150268.diff

2 Files Affected:

  • (modified) lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp (+2-1)
  • (modified) lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py (+11)
diff --git a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
index a2c34ddfc252e..4c6d584383747 100644
--- a/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
+++ b/lldb/source/Plugins/Process/gdb-remote/ProcessGDBRemote.cpp
@@ -4783,7 +4783,8 @@ bool ParseRegisters(
             } else if (gdb_type == "data_ptr" || gdb_type == "code_ptr") {
               reg_info.format = eFormatAddressInfo;
               reg_info.encoding = eEncodingUint;
-            } else if (gdb_type == "float") {
+            } else if (gdb_type == "float" || gdb_type == "ieee_single" ||
+                       gdb_type == "ieee_double") {
               reg_info.format = eFormatFloat;
               reg_info.encoding = eEncodingIEEE754;
             } else if (gdb_type == "aarch64v" ||
diff --git a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
index 9a70f67b264ce..db5b5a0e0d0cb 100644
--- a/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
+++ b/lldb/test/API/functionalities/gdb_remote_client/TestGDBServerTargetXML.py
@@ -692,6 +692,9 @@ class MyResponder(MockGDBServerResponder):
                 "0102030405060708"  # t4
                 "0102030405060708"  # t5
                 "0102030405060708"  # t6
+                "6162636465666768"  # pc
+                "0000C03F"  # ft0
+                "e07a6147a8a40940"  # ft1
             )
 
             def qXferRead(self, obj, annex, offset, length):
@@ -737,6 +740,10 @@ def qXferRead(self, obj, annex, offset, length):
                                 <reg name="t6" bitsize="64" type="int"/>
                                 <reg name="pc" bitsize="64" type="code_ptr"/>
                             </feature>
+                            <feature name='org.gnu.gdb.riscv.fpu'>
+                                <reg name='ft0' bitsize='32' type='ieee_single'/>
+                                <reg name='ft1' bitsize='64' type='ieee_double'/>
+                            </feature>
                         </target>""",
                         False,
                     )
@@ -799,6 +806,10 @@ def haltReason(self):
         self.match("register read x29", ["t4 = 0x0807060504030201"])
         self.match("register read x30", ["t5 = 0x0807060504030201"])
         self.match("register read x31", ["t6 = 0x0807060504030201"])
+        self.match("register read pc", ["pc = 0x6867666564636261"])
+        # test FPU registers
+        self.match("register read ft0", ["ft0 = 1.5"])
+        self.match("register read ft1", ["ft1 = 3.2053990913985757"])
 
     @skipIfXmlSupportMissing
     @skipIfRemote

@satyajanga satyajanga changed the title support ieee_single and ieee_double gdbtypes for registers [lldb] support ieee_single and ieee_double gdbtypes for registers Jul 27, 2025
Copy link
Collaborator

@DavidSpickett DavidSpickett left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me, nice to see more GDB compatibility, but I'll leave it to your chosen reviewers to approve.

"0102030405060708" # t4
"0102030405060708" # t5
"0102030405060708" # t6
"6162636465666768" # pc
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess that we just didn't provide data for the PC before? Surprised that the test worked at all.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test also was't validating for pc before. the stop reply packet (from haltReason func) has the PC

@satyajanga
Copy link
Contributor Author

Looks good to me, nice to see more GDB compatibility, but I'll leave it to your chosen reviewers to approve.

Thank you for your review. the review bot only assigned one reviewer. so I added some more internal reviewers to get faster review.

@Jlalond Jlalond merged commit ea480cc into llvm:main Jul 28, 2025
12 checks passed
@Jlalond
Copy link
Contributor

Jlalond commented Jul 28, 2025

@satyajanga merged for you

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants